import axios from 'axios';

const BASE_URL = 'http://localhost:8080/deviceData';

// 获取历史数据
export const fetchHistoryData = (dataType) => {
    return axios.get(`${BASE_URL}/history`, {
        params: { dataType },
    });
};

// 获取最新数据并保存
export const fetchAndSaveData = (dataType, boxNo) => {
    const params = new URLSearchParams();
    params.append('dataType', dataType);
    params.append('boxNo', boxNo);

    return axios.post(`${BASE_URL}/fetchAndSave`, params, {
        headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    });
};

